#!/bin/sh 2

server_name="server_manager.server"

pid=$(ps ax | grep -i "${server_name}" | grep "${target_dir}" | grep java | grep -v grep | awk '{print $1}')

if [ -z "${pid}" ]; then
echo "No ${server_name} server is running."
exit 1
fi

echo "The ${server_name} server (pid: ${pid}) is running, sending shutdown request..."

kill "${pid}"

echo "Shutdown request sent to ${server_name} server (pid: ${pid}) successfully."